Merged from gtk-2-6:
authorFederico Mena Quintero <federico@ximian.com>
Tue, 3 May 2005 01:55:33 +0000 (01:55 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Tue, 3 May 2005 01:55:33 +0000 (01:55 +0000)
2005-05-02  Federico Mena Quintero  <federico@ximian.com>

Merged from gtk-2-6:

Fixes #301068:

* gtk/gtkfilesystemunix.c (struct _GtkFileSystemUnix): Add fields
to store struct stat for /afs and /net, and boolean fields to say
whether these are valid.
(struct _GtkFileFolderUnix): Added a boolean is_network_dir field.
(gtk_file_system_unix_get_folder): Fill in the is_network_dir
field of the folder structure.
(fill_in_names): If the folder is a network directory, create a
fake struct stat for its entries.
(fill_in_stats): Don't stat() the children of network directories.

* gtk/gtkfilechooserdefault.c (list_mtime_data_func): If the mtime
is 0, use "Unknown" for the cell's displayed text.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gtk/gtkfilechooserdefault.c
gtk/gtkfilesystemunix.c

index 730c7586e65a1f0031fe63f50a644c9dd8c449e4..715c64ec44f850e3fbf6eaa7c69472f4bba417ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2005-05-02  Federico Mena Quintero  <federico@ximian.com>
+
+       Merged from gtk-2-6:
+
+       Fixes #301068:
+
+       * gtk/gtkfilesystemunix.c (struct _GtkFileSystemUnix): Add fields
+       to store struct stat for /afs and /net, and boolean fields to say
+       whether these are valid.
+       (struct _GtkFileFolderUnix): Added a boolean is_network_dir field.
+       (gtk_file_system_unix_get_folder): Fill in the is_network_dir
+       field of the folder structure.
+       (fill_in_names): If the folder is a network directory, create a
+       fake struct stat for its entries.
+       (fill_in_stats): Don't stat() the children of network directories.
+
+       * gtk/gtkfilechooserdefault.c (list_mtime_data_func): If the mtime
+       is 0, use "Unknown" for the cell's displayed text.
+
 2005-04-28  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwidget.c: Add a draw-border style property to allow
index 730c7586e65a1f0031fe63f50a644c9dd8c449e4..715c64ec44f850e3fbf6eaa7c69472f4bba417ba 100644 (file)
@@ -1,3 +1,22 @@
+2005-05-02  Federico Mena Quintero  <federico@ximian.com>
+
+       Merged from gtk-2-6:
+
+       Fixes #301068:
+
+       * gtk/gtkfilesystemunix.c (struct _GtkFileSystemUnix): Add fields
+       to store struct stat for /afs and /net, and boolean fields to say
+       whether these are valid.
+       (struct _GtkFileFolderUnix): Added a boolean is_network_dir field.
+       (gtk_file_system_unix_get_folder): Fill in the is_network_dir
+       field of the folder structure.
+       (fill_in_names): If the folder is a network directory, create a
+       fake struct stat for its entries.
+       (fill_in_stats): Don't stat() the children of network directories.
+
+       * gtk/gtkfilechooserdefault.c (list_mtime_data_func): If the mtime
+       is 0, use "Unknown" for the cell's displayed text.
+
 2005-04-28  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwidget.c: Add a draw-border style property to allow
index 730c7586e65a1f0031fe63f50a644c9dd8c449e4..715c64ec44f850e3fbf6eaa7c69472f4bba417ba 100644 (file)
@@ -1,3 +1,22 @@
+2005-05-02  Federico Mena Quintero  <federico@ximian.com>
+
+       Merged from gtk-2-6:
+
+       Fixes #301068:
+
+       * gtk/gtkfilesystemunix.c (struct _GtkFileSystemUnix): Add fields
+       to store struct stat for /afs and /net, and boolean fields to say
+       whether these are valid.
+       (struct _GtkFileFolderUnix): Added a boolean is_network_dir field.
+       (gtk_file_system_unix_get_folder): Fill in the is_network_dir
+       field of the folder structure.
+       (fill_in_names): If the folder is a network directory, create a
+       fake struct stat for its entries.
+       (fill_in_stats): Don't stat() the children of network directories.
+
+       * gtk/gtkfilechooserdefault.c (list_mtime_data_func): If the mtime
+       is 0, use "Unknown" for the cell's displayed text.
+
 2005-04-28  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwidget.c: Add a draw-border style property to allow
index e8922210faa6cebe7698089b0584b40f2766c329..0dcb89fea01041ea86926b96eee6e253415e9f05 100644 (file)
@@ -6300,28 +6300,34 @@ list_mtime_data_func (GtkTreeViewColumn *tree_column,
     }
 
   time_mtime = gtk_file_info_get_modification_time (info);
-  g_date_set_time (&mtime, (GTime) time_mtime);
 
-  time_now = (GTime ) time (NULL);
-  g_date_set_time (&now, (GTime) time_now);
-
-  days_diff = g_date_get_julian (&now) - g_date_get_julian (&mtime);
-
-  if (days_diff == 0)
-    strcpy (buf, _("Today"));
-  else if (days_diff == 1)
-    strcpy (buf, _("Yesterday"));
+  if (time_mtime == 0)
+    strcpy (buf, _("Unknown"));
   else
     {
-      char *format;
+      g_date_set_time (&mtime, (GTime) time_mtime);
+
+      time_now = (GTime ) time (NULL);
+      g_date_set_time (&now, (GTime) time_now);
+
+      days_diff = g_date_get_julian (&now) - g_date_get_julian (&mtime);
 
-      if (days_diff > 1 && days_diff < 7)
-       format = "%A"; /* Days from last week */
+      if (days_diff == 0)
+       strcpy (buf, _("Today"));
+      else if (days_diff == 1)
+       strcpy (buf, _("Yesterday"));
       else
-       format = "%x"; /* Any other date */
+       {
+         char *format;
+
+         if (days_diff > 1 && days_diff < 7)
+           format = "%A"; /* Days from last week */
+         else
+           format = "%x"; /* Any other date */
 
-      if (g_date_strftime (buf, sizeof (buf), format, &mtime) == 0)
-       strcpy (buf, _("Unknown"));
+         if (g_date_strftime (buf, sizeof (buf), format, &mtime) == 0)
+           strcpy (buf, _("Unknown"));
+       }
     }
 
   if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
index 0be36681e49ac441285af37900b2f54fc37b248b..54e02aa3ef0840d0c5901bead67a6563ac78fe92 100644 (file)
@@ -61,6 +61,13 @@ struct _GtkFileSystemUnix
   GObject parent_instance;
 
   GHashTable *folder_hash;
+
+  /* For /afs and /net */
+  struct stat afs_statbuf;
+  struct stat net_statbuf;
+
+  guint have_afs : 1;
+  guint have_net : 1;
 };
 
 /* Icon type, supplemented by MIME type
@@ -102,8 +109,9 @@ struct _GtkFileFolderUnix
   GtkFileInfoType types;
   gchar *filename;
   GHashTable *stat_info;
-  unsigned int have_stat : 1;
-  unsigned int have_mime_type : 1;
+  guint have_stat : 1;
+  guint have_mime_type : 1;
+  guint is_network_dir : 1;
   time_t asof;
 };
 
@@ -321,6 +329,16 @@ static void
 gtk_file_system_unix_init (GtkFileSystemUnix *system_unix)
 {
   system_unix->folder_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
+  if (stat ("/afs", &system_unix->afs_statbuf) == 0)
+    system_unix->have_afs = TRUE;
+  else
+    system_unix->have_afs = FALSE;
+
+  if (stat ("/net", &system_unix->net_statbuf) == 0)
+    system_unix->have_net = TRUE;
+  else
+    system_unix->have_net = FALSE;
 }
 
 static void
@@ -416,6 +434,8 @@ gtk_file_system_unix_get_folder (GtkFileSystem     *file_system,
       int code;
       int my_errno;
 
+      code = my_errno = 0; /* shut up GCC */
+
       result = stat (filename, &statbuf);
 
       if (result == 0)
@@ -461,6 +481,16 @@ gtk_file_system_unix_get_folder (GtkFileSystem     *file_system,
       folder_unix->have_mime_type = FALSE;
       folder_unix->have_stat = FALSE;
 
+      if ((system_unix->have_afs &&
+          system_unix->afs_statbuf.st_dev == statbuf.st_dev &&
+          system_unix->afs_statbuf.st_ino == statbuf.st_ino) ||
+         (system_unix->have_net &&
+          system_unix->net_statbuf.st_dev == statbuf.st_dev &&
+          system_unix->net_statbuf.st_ino == statbuf.st_ino))
+       folder_unix->is_network_dir = TRUE;
+      else
+       folder_unix->is_network_dir = FALSE;
+
       g_hash_table_insert (system_unix->folder_hash,
                           folder_unix->filename,
                           folder_unix);
@@ -2096,13 +2126,20 @@ fill_in_names (GtkFileFolderUnix *folder_unix, GError **error)
 
   while (TRUE)
     {
-      const gchar *basename = g_dir_read_name (dir);
+      struct stat_info_entry *entry;
+      const gchar *basename;
+
+      basename = g_dir_read_name (dir);
       if (!basename)
        break;
 
+      entry = g_new0 (struct stat_info_entry, 1);
+      if (folder_unix->is_network_dir)
+       entry->statbuf.st_mode = S_IFDIR;
+
       g_hash_table_insert (folder_unix->stat_info,
                           g_strdup (basename),
-                          g_new0 (struct stat_info_entry, 1));
+                          entry);
     }
 
   g_dir_close (dir);
@@ -2140,9 +2177,10 @@ fill_in_stats (GtkFileFolderUnix *folder_unix)
   if (!fill_in_names (folder_unix, NULL))
     return;
 
-  g_hash_table_foreach_remove (folder_unix->stat_info,
-                              cb_fill_in_stats,
-                              folder_unix);
+  if (!folder_unix->is_network_dir)
+    g_hash_table_foreach_remove (folder_unix->stat_info,
+                                cb_fill_in_stats,
+                                folder_unix);
 
   folder_unix->have_stat = TRUE;
 }